using UnityEngine;

public static class HalfCircleMeshCalculator
{
	public static void CreateHalfCircleDownPart(int xSize, float width, out Vector3[] vertList, out int[] triList)
	{
		CreateHalfCirclePart(xSize, width, out vertList, out triList, 90f);
	}

	public static void CreateHalfCircleTopPart(int xSize, float width, out Vector3[] vertList, out int[] triList)
	{
		CreateHalfCirclePart(xSize, width, out vertList, out triList, -90f);
	}

	private static void CreateHalfCirclePart(int xSize, float width, out Vector3[] vertList, out int[] triList, float angleOffset)
	{
		vertList = new Vector3[xSize];
		vertList[0] = Vector3.zero;
		float num = 180f / (float)(xSize - 2);
		Vector3 b = new Vector3(width * (float)xSize, width * (float)xSize);
		for (int i = 1; i < xSize; i++)
		{
			vertList[i] = Quaternion.AngleAxis(angleOffset + num * (float)(i - 1), Vector3.back) * Vector3.up;
			vertList[i] = Vector3.Scale(vertList[i], b);
		}
		GenerateTriangles(xSize, out triList);
	}

	private static void GenerateTriangles(int numVerts, out int[] triList)
	{
		triList = new int[numVerts * 3];
		for (int i = 0; i + 2 < numVerts; i++)
		{
			int num = i * 3;
			triList[num] = 0;
			triList[num + 1] = i + 1;
			triList[num + 2] = i + 2;
		}
	}
}
